package com.shop.cereshop.commons.domain.qrcode;

import lombok.Getter;
import lombok.Setter;

/**
 * 二维码类型枚举
 */
public enum QrCodeTypeEnum {
    USER_QR_CODE(1, "用户二维码"),
    SHOP_QR_CODE(2, "店铺二维码"),
    PRODUCT_QR_CODE(3, "商品二维码"),
    ORDER_QR_CODE(4, "订单二维码"),
    SHOP_COMMENT_QR_CODE(5, "店铺评价二维码"),
    PRODUCT_COMMENT_QR_CODE(6, "商品评价二维码"),
    SHOP_COLLECT_QR_CODE(7, "店铺收藏二维码"),
    PRODUCT_COLLECT_QR_CODE(8, "商品收藏二维码");

    /**
     * 二维码类型code
     */
    @Getter
    @Setter
    private Integer code;
    /**
     * 二维码类型名称
     */
    @Getter
    @Setter
    private String name;


    QrCodeTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }


    public static String getName(Integer code) {
        for (QrCodeTypeEnum value : QrCodeTypeEnum.values()) {
            if (value.getCode().equals(code)) {
                return value.getName();
            }
        }
        return null;
    }

    public static QrCodeTypeEnum getEnum(Integer code) {
        for (QrCodeTypeEnum value : QrCodeTypeEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
}
